#ifndef DATA_LINK_H_
#define DATA_LINK_H_

// Frame Declarations
#define MAX_FRAME 255
#define MAX_CFRAME 5
#define MAX_FRAME_SIZE 1000

#define FLAG 0x7E
#define ADDRESS 0x03
#define C_SET 0x03
#define C_DISC 0x0D
#define C_UA 0x07
#define C_RR0 (0x01 | (0x00 << 5))
#define C_REJ0 (0x05 | (0x00 << 5))
#define C_RR1 (0x01 | (0x01 << 5))
#define C_REJ1 (0x05 | (0x01 << 5))
#define C_S(r) (r << 1)
#define BCC(c) (ADDRESS ^ c)

#define ESC 0x7d

#define TIME_OUT 3
#define MAX_TIMEOUTS 3

#define MAX_READS_FILE 3
#define MAX_TRIES 3

#define FRAME_RD_TIMEOUT 0
#define FRAME_READ 1

void write_cframe(int fd, char control);
int write_iframe(int fd, char control, char* packet, int p_len);
int read_cframe(int fd, char cframe[]);
int read_iframe(int fd, char* buf);

#endif // DATA_LINK_H_
